using CodeMonkey.MonoBehaviours;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameHandler_Setup : MonoBehaviour
{
    
    private Vector3 cameraPosition;
    private float orthoSize = 40f;
    Camera myCamera;

    private void Start()
    {
        cameraPosition = transform.position;
        myCamera = GetComponent<Camera>();
        myCamera.orthographicSize = orthoSize;
    }

    private void Update()
    {
        float cameraSpeed = 100f;
        Vector3 curPosition = transform.position;
        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
        {
            cameraPosition += new Vector3(-1, 0) * cameraSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
        {
            cameraPosition += new Vector3(+1, 0) * cameraSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
        {
            cameraPosition += new Vector3(0, +1) * cameraSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
        {
            cameraPosition += new Vector3(0, -1) * cameraSpeed * Time.deltaTime;
        }
        transform.position = Vector3.MoveTowards(curPosition, cameraPosition, cameraSpeed * Time.deltaTime*0.5f);

        //Zoom out
        if (Input.GetAxis("Mouse ScrollWheel")>0)
        {
            orthoSize -= 100f * Time.deltaTime;
        }
        //Zoom In
        if (Input.GetAxis("Mouse ScrollWheel")<0)
        {
            orthoSize += 100f * Time.deltaTime;
        }
        myCamera.orthographicSize=orthoSize;
    }
}
